package com.zrrd.thread._04_sleep;

/**
 * @author WanJl
 * @version 1.0
 * @title MyRunnable
 * @description
 * @create 2023/10/29 11:55
 */
public class MyRunnable implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            try {
                //sleep(long ms)。让当前的线程睡眠ms毫秒
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"----"+i);
        }
    }

    public static void main(String[] args) {
        Thread t1 = new Thread(new MyRunnable(), "线程1");
        Thread t2 = new Thread(new MyRunnable(), "线程2");

        t1.start();
        t2.start();
    }
}
